﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using mfe.bll;

namespace mfe_proj.Forms
{
    public delegate void CountryFormEventHandler(object sender, EventArgs e);

    public partial class CountryForm : Form
    {
        public event CountryFormEventHandler CountryAdded;
        public CountryForm()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim().Length == 0)
            {
                MessageBox.Show("Enter at least a name");
                return;
            }

            Country c = new Country();
            c.Name = txtName.Text.Trim();
            c.Abbreviation = txtAbbr.Text.Trim();
            c.ChineseName = txtChineseName.Text.Trim();
            if (c.Save())
            {
                if (CountryAdded != null) CountryAdded(sender, e);
                Close();
            }
        }
    }

    /*
    public class CountryFormEventArgs : EventArgs
    {
    }
    */
}
